<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
//还可以采用动态定义路由规则的方式定义，例如在路由配置文件（ application/route.php ）的开头直接添加下面的方法：
use think\Route;
//Route::rule('hello/:name','index/hello');
//Route::rule(':version/user/:id','api/:version.User/read');
return [
    '__pattern__' => [
//        'name' => '\w+',
        'id' => '\d+',
    ],
//    '[hello]' => [
//        ':id' => ['index/hello', ['method' => 'get'], ['id' => '\d+']],
//        ':name' => ['index/hello', ['method' => 'post']],
//    ],
    //'hello/:name' => 'index/index/hello',访问地址为，域名/hello/tinkephp,必须带参数否则找不到，下面为改进
//    [] 把路由规则中的变量包起来，就表示该变量为可选，
//    'hello/[:name]' => 'index/index/hello',
    //完整匹配路由写法，以$符号结尾
//    'hello/[:name]$'=> 'index/index/hello',
    //当我们访问下面的URL地址的时候：
    // http://tp5.com/hello // 正确匹配
    // http://tp5.com/hello/thinkphp //正确匹配
    // http://tp5.com/hello/thinkphp/val/value // 不会匹配

//    闭包写法
    /*'hello/[:name]' => function($name){
    return 'bibaoxiefa'.$name;
    },*/
    'hello/[:name]' => ['/index/index/hello', ['method' => 'get', 'ext' => 'html']],
    //复杂写法
    /*'blog/:year/:month' => ['blog/archive', ['method' => 'get'], ['year' => '\d{4}', 'm onth' => '\d{2}']],
    'blog/:id' => ['blog/get', ['method' => 'get'], ['id' => '\d+']],
    'blog/:name' => ['blog/read', ['method' => 'get'], ['name' => '\w+']],*/
    //因为都是blog开头，复杂简写写法
//    '[blog]' => [
//        ':year/:month' => ['blog/archive', ['method' => 'get'], ['year' => '\d{4}', 'mo nth' => '\d{2}']],
//        ':id' => ['blog/get', ['method' => 'get'], ['id' => '\d+']],
//        ':name' => ['blog/read', ['method' => 'get'], ['name' => '\w+']],
//        ],
    //下面写法省略了模块会搜寻默认模块Index
    'blog/:id' => 'blog/get',
    'blog/:name' => 'blog/read',
    'blog-<year>-<month>' => 'blog/archive',

    //自由测试路由
//    'test/:name' => 'index/test/index',
//    'test/geturl' => 'index/test/geturl',
//    '[test]' => [
//        'geturl' => 'index/test/geturl',
//        'getParam' => 'index/test/getparam',
//        'input' => 'index/test/getParamforInput',
//        'other' => 'index/test/getOther',
//        'tt' => 'index/test/gettt',
//        'reponse' => 'index/test/testReponse',
//        'red' => 'index/test/testRedirect',
//        ':name' => 'index/test/index',
//    ],
//    '[data]' => [
//        'get' => 'index/Data/index',
//        'reg' => 'index/Data/reg',
//        'reg2' => 'index/Data/reg2'
//    ],
//    'user/index' => 'index/user/index',
//    'user/create' => 'index/user/create',
//    'user/add' => 'index/user/add',
//    'user/add2' => 'index/user/add2',
//    'user/addlist' => 'index/user/addList',
//    'user/update/:id' => 'index/user/update',
//    'user/delete/:id' => 'index/user/delete',
//    'user/:id' => 'index/user/read',
//
//    //下面为一对一关联路由
//    'user/addone'=>'index/user/addone',
//    'user/readone'=>'index/user/readone',
//    'user/upone'=>'index/user/updateone',
//    'user/delone'=>'index/user/deleteone',
//
//    //下面为一对多关联路由
//
//    'user/bookadd' => 'index/user/addbook',
//    'user/bookaddall' => 'index/user/addbookAll',
//    'user/readbook' => 'index/user/readBook',
//    'user/upbook' => 'index/user/updateBook',
//    'user/delbook' => 'index/user/deletebook',
//    'user/delbookAll' => 'index/user/deletebookALl',
//
//    //下面为多对多编辑
//    'user/addmany' => 'index/user/addMany',
//
//    'user/personadd' => 'index/person/addPerson',
    'user/person/read' => 'index/person/read',

    //下面为正式项目代码(控制器有多层，就需要用 目录.控制器
    'user/login' => 'api/user.user/login', //用户登录
    'user/loginout' => 'api/user.user/loginout', //用户登出
    'user/regist' => 'api/user.user/reg', //用户注册
    'user/getUserDetail' => 'api/user.user/getUserDetail', // 获得用户详情
    'user/getUserDongTai' => 'api/user.user/getUserDongTai', // 获得用户发布的动态
    'user/addaddress' => 'api/user.user/addaddress', //增加收货地址
    'user/getaddress' => 'api/user.user/getaddress', //增加收货地址
    'user/addorder' => 'api/user.user/addorder', //增加收货地址
    'user/addguanzhu' => 'api/user.user/addguanzhu', // 添加关注用户
    'user/cancelguanzhu' => 'api/user.user/cancleGuanZhu', // 取消关注用户
    'user/delSelfDongTai' => 'api/user.user/delSelfDongTai', // 删除用户的动态
    
    'user/getGuanZhuList' => 'api/user.user/getGuanZhuList', // 获取关注用户列表
    'user/getFansList' => 'api/user.user/getFansList', // 获取粉丝用户列表
    'user/updateUserInfo' => 'api/user.user/updateUserInfo', //更新用户资料
    
    'home/getRecommendData' => 'api/home.home/getRecommendData', // 根据场景获取首页数据
    'getFindData' => 'api/home.home/getFindData', // 根据场景获得发现页数据
    'getlaunchimg' => 'api/home.home/getlaunch', // 获得启动图
    'uploadVideoCover' => 'api/home.home/uploadVideoCover', // 上传视频封面
    'uploadFile' => 'api/home.home/uploadFile', // 发布动态时调用的api

    
    'getDianZan' => 'api/dongtaidetail.DongTaiDetail/getDianZan', // 获得点赞列表
    'getPinlun' => 'api/dongtaidetail.DongTaiDetail/getPinlun', // 获得评论列表
    'addPinlun' => 'api/dongtaidetail.DongTaiDetail/addPinlun', // 添加评论
    'addDianzan' => 'api/dongtaidetail.DongTaiDetail/addDianzan', // 添加点赞
    'cancelDianzan' => 'api/dongtaidetail.DongTaiDetail/cancelDianzan', // 取消点赞
    'addShouChang' => 'api/dongtaidetail.DongTaiDetail/addShouChang', // 添加收藏
    'cancelShouChang' => 'api/dongtaidetail.DongTaiDetail/cancelShouChang', // 取消收藏
    
    // 管理员模块
    'admin/getAllUser' => 'api/admin.user/getAllUser', // 获取所有用户
    'admin/getCoutUser' => 'api/admin.user/getCoutUser', // 获取所有用户的数量
    'admin/delUser' => 'api/admin.user/delUser', // 删除用户根据id
    'admin' => 'api/admin.user/index', // 测试api
    
    'test' => 'api/home.home/test',
];
